<html>
<head>
    <title>添加</title>
    <meta charset="UTF-8">
</head>
<link rel="stylesheet" href="/static/layui/css/layui.css" />
<body>

<form class="layui-form"  action="" lay-filter="edit">
    <div class="layui-form-item">
        <div class="layui-input-inline layui-col-md8">
            <input type="hidden" name="loid" id="loid"  required  lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名：</label>
        <div class="layui-input-inline layui-col-md7">
            <input type="text" name="loname" id="loname"  required  lay-verify="required" placeholder="..." autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">身份证：</label>
        <div class="layui-input-inline layui-col-md1">
            <input type="text" name="loidcard" id="loidcard"  required  lay-verify="required" placeholder="..." autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电话：</label>
        <div class="layui-input-inline layui-col-md2">
            <input type="text" name="lotel" id="lotel"  required  lay-verify="required" placeholder="..." autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">时间：</label>
        <div class="layui-input-inline layui-col-md3">
            <input type="text" name="lotime" id="lotime"  required  lay-verify="required" placeholder="..." autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
        </div>
    </div>
</form>
</body>

<script src="/static/js/system.js"></script>
<script src="/static/js/jquery-3.3.1.js"></script>
<script src="/static/layui/layui.js"></script>
<script>
    //Demo
    layui.use(['form','laydate'], function(){
        var form = layui.form;
        var laydate = layui.laydate;
        $.ajax({
            url:'/LogisticsServlet?method=queryOne',
            dataType:"json",
            data:{"id":getQueryString("id")},
            success:function (da) {
                console.log(da);
                if (da.code == 0) {
                        // form.val("edit",da.data);
                    $.each(da.data,function (index,i) {
                        $('#loid').val(i.loid);
                        $("#loname").val(i.loname);
                        $('#loidcard').val(i.loidcard);
                        $('#lotel').val(i.lotel);
                        $('#lotime').val(layui.util.toDateString(i.lotime,'yyyy-MM-dd'));
                    })
                } else {
                    layer.msg("查询数据失败！");
                }
            }
        });
        //监听提交 15039939677
        form.on('submit(formDemo)', function(data){
            var data1 = form.val("edit");
            console.log(data1);
            $.ajax({
                url:'/LogisticsServlet?method=update',
                type:"post",
                data:data1,
                dataType:"json",
                success:function (da) {
                    if (da.code == 0) {
                        console.log(da);
                        layer.alert("修改成功！", function () {
                            // window.parent.location.reload();//刷新父页面
                            // parent.layer.close(layer.index);//关闭弹出层
                            parent.layer.closeAll();
                        });
                    } else {
                        layer.msg("修改失败！");
                    }
                }
            });
            return false;
        });
        laydate.render({
            elem: '#lotime'    //指定元素test1
        });
    });
</script>
</html>
